using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class AttackBackJump : MonoBehaviour
{
    public UnityEvent OnAttackBackJump;

    public float m_BackXSpeed = 5;
    public float m_BackYSpeed = 5;

    public void Execute()
    {
        OnAttackBackJump?.Invoke();
    }

    public void Execute(GameObject obj)
    {
        var rigidbody = obj.GetComponent<Rigidbody2D>();
        var offPos = obj.transform.position.x - gameObject.transform.position.x;
        var dir = Mathf.Sign(offPos);
        rigidbody.velocity = new Vector2(m_BackXSpeed * dir, m_BackYSpeed);
    }
}
